package com.ebt.m.customer.view;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;
import android.view.WindowManager;

import com.ebt.m.R;

/**
 * 此view用来显示客户主界面上部的“新增”、“建议”、“追踪”等的UI单元，包括上部的“数量”和下部的“类别”
 * @author Rick.Wang
 *
 */
public class HeaderUnitView extends View {

	private static final int DEFAULT_COLOR_BACKGROUND = 0xffffffff;//默认背景颜色
	private static final int DEFAULT_COLOR_TYPE = 0xffffffff;

    private String mTextUp = "";
    private String mTextDown = "";

	public HeaderUnitView(Context context) {
		this(context, null);
	}

	public HeaderUnitView(Context context, AttributeSet attrs) {
		this(context, attrs, 0);
	}

	public HeaderUnitView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);

		TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.maxHeightView);

		final int count = a.getIndexCount();
        for (int i = 0; i < count; ++i) {
            int attr = a.getIndex(i);
            switch (attr) {
            case R.styleable.maxHeightView_maxHeightRatio:
//            	mMaxRatio = a.getFloat(attr, DEFAULT_MAX_RATIO);
                break;
            case R.styleable.maxHeightView_maxHeightDimen:
//            	mMaxHeight = a.getDimension(attr, DEFAULT_MAX_HEIGHT);
                break;
            }
        }
        a.recycle();

	}

	@Override
	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

		int heightMode = MeasureSpec.getMode(heightMeasureSpec);
		int heightSize = MeasureSpec.getSize(heightMeasureSpec);


		if(heightMode == MeasureSpec.EXACTLY){
//			heightSize = heightSize <= mMaxHeight ? heightSize : (int)mMaxHeight;
		}
		if(heightMode == MeasureSpec.UNSPECIFIED){
//			heightSize = heightSize <= mMaxHeight ? heightSize : (int)mMaxHeight;
		}
		if(heightMode == MeasureSpec.AT_MOST){
//			heightSize = heightSize <= mMaxHeight ? heightSize : (int)mMaxHeight;
		}

		int maxHeightMeasureSpec = MeasureSpec.makeMeasureSpec(heightSize, heightMode);
		
		super.onMeasure(widthMeasureSpec, maxHeightMeasureSpec);
	}
	
	/**
	 * 获取屏幕高度
	 * @param context
	 */
	public static int getScreenHeight(Context context){
		WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
		return wm.getDefaultDisplay().getHeight();
	}
	
	/**
	 * 获取屏幕宽度
	 * @param context
	 */
	public static int getScreenWidth(Context context){
		WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
		return wm.getDefaultDisplay().getWidth();
	}
	
	/**
	 * 获取屏幕大小
	 * @param context
	 * @param outDimension
	 */
	public static void getScreenDimension(Context context, int[] outDimension){
		WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
		outDimension[0] = wm.getDefaultDisplay().getWidth();
		outDimension[1] = wm.getDefaultDisplay().getHeight();
	}

}
